/**
 * 
 */
package com.ginger.countdown;

import java.util.concurrent.CountDownLatch;

/**
 * @Description: 监控中心 
 * @author 姜锋
 * @date 2018年8月20日 下午2:00:58 
 * @version V1.0   
 *	抽象类 监控中心 统一检查
 *	
 */
public abstract class MonitorCenter implements Runnable{
	
	//计数器
	private CountDownLatch countDown;
	//调度站
	private String station;
	//调度站对自己站点进行检查,是否合格
	private boolean ok;
	public MonitorCenter(CountDownLatch countDown, String station) {
		this.countDown = countDown;
		this.station = station;
		ok = false;
	}
	
	
	
	@Override
	public void run() {
		
		try {
			check();
			ok = true;
		} catch (Exception e) {
			e.printStackTrace();
			ok = false;
		}finally {
			if(countDown != null) {
				
				countDown.countDown();
			}
		}
		
	}
	
	
	public abstract void check();
	
	/**
	 * @return countDown
	 */
	public CountDownLatch getCountDown() {
		return countDown;
	}
	/**
	 * @param countDown 要设置的 countDown
	 */
	public void setCountDown(CountDownLatch countDown) {
		this.countDown = countDown;
	}
	/**
	 * @return station
	 */
	public String getStation() {
		return station;
	}
	/**
	 * @param station 要设置的 station
	 */
	public void setStation(String station) {
		this.station = station;
	}
	/**
	 * @return ok
	 */
	public boolean isOk() {
		return ok;
	}
	/**
	 * @param ok 要设置的 ok
	 */
	public void setOk(boolean ok) {
		this.ok = ok;
	}
	
	
	

}
